#include "block.h"

void Block::drawUpperPartialDisk(){
    GLUquadricObj *pObj;
    pObj = gluNewQuadric();
    gluQuadricNormals(pObj, GLU_FILL);
    glPushMatrix() ;

    double y_trans = 0.5*(i);
    double x_trans= opening_angle*j;
//    if(x_trans>90)
//        x_trans=90-x_trans;

    glTranslated(0,2.75-y_trans-0.1,-7.0);
    glScaled (2.0,2.0,2.0);
    glRotated(90, 1,0,0);
    gluPartialDisk(pObj, in_radius , out_radius, 100,100, x_trans, opening_angle);
    glPopMatrix();
}

void Block::drawBottomPartialDisk(){
    GLUquadricObj *pObj;
    pObj = gluNewQuadric();
    gluQuadricNormals(pObj, GLU_FILL);
    glPushMatrix() ;

    double y_trans = 0.5*(i);
    double x_trans= opening_angle*j;
//    if(x_trans>90)
//        x_trans=90-x_trans;

    glTranslated(0,2.25-y_trans,-7.0);
    glScaled (2.0,2.0,2.0);
    glRotated(90, 1,0,0);
    gluPartialDisk(pObj, in_radius , out_radius, 100,100, x_trans, opening_angle);
    glPopMatrix();
}

void Block::drawMiddleBand (){

}

void Block::drawBlock(){
    GLfloat mat_emission[] = { 0.0, 0.0, 0.0, 0.0 };
    GLfloat mat_ambient [] = { 0.3, 0.5, 0.7, 1.0 };
    GLfloat mat_diffuse [] = { 0.8, 0.2, 0.2, 1.0 };
    GLfloat mat_specular[] = { 0.1, 0.1, 0.1, 1.0 };

    glMaterialfv( GL_FRONT, GL_EMISSION, mat_emission );
    glMaterialfv( GL_FRONT, GL_AMBIENT,  mat_ambient  );
    glMaterialfv( GL_FRONT, GL_DIFFUSE,  mat_diffuse  );
    glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular );
    glMaterialf ( GL_FRONT, GL_SHININESS, 40.0 );

//    printf("%d %d \n",i,j);

    drawUpperPartialDisk();
    drawBottomPartialDisk();
}
